<!DOCTYPE html>
<html lang="zh">
<head>
    <th:block th:include="include :: header('发送指令')"/>
    <style>
        .control-label {
            height: 31px;
            line-height: 31px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated ibox-content">
    <input name="boatCode" th:value="${boat.code}" type="hidden">
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">平台模式切换：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="1" id="optionsRadios1" name="mode">手动
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="2" id="optionsRadios2" name="mode" checked>自动
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendMode()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>

            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">北斗目标地址（平台地址）：</label>
                <div class="col-sm-6">
                    <input type="text" name="address" oninput = "value=value.replace(/[^\d]/g,'')"
                           class="form-control" placeholder="请输入修改的北斗目标地址">
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendAddress()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
<!--    <hr>-->
<!--    <div class="row">-->
<!--        <div class="col-sm-12">-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">艇端ID修改：</label>-->
<!--                <div class="col-sm-6">-->
<!--                    <input type="text" name="boatid" class="form-control" placeholder="请输入修改的艇ID">-->
<!--                </div>-->
<!--                <div class="col-sm-2">-->
<!--                    <button class="btn btn-primary " type="button" onclick="sendBoatID()"><i class="fa fa-send-o"></i>&nbsp;发送-->
<!--                    </button>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">艇端数据上报频率修改：</label>
                <div class="col-sm-6">
                    <input type="text" name="boatfrequency" class="form-control" oninput = "value=value.replace(/[^\d]/g,'')"
                           placeholder="请输入修改的时间（0-255分钟）">
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendBoatTime()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
<!--    <hr>-->
<!--    <div class="row">-->
<!--        <div class="col-sm-12">-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">发送模式切换：</label>-->
<!--                <div class="col-sm-6">-->
<!--                    <label class="radio-box">-->
<!--                        <input type="radio" value="0" id="optionsRadios3" name="sendMode">北斗二代-->
<!--                    </label>-->
<!--                    <label class="radio-box">-->
<!--                        <input type="radio" value="1" id="optionsRadios4" name="sendMode">北斗三代-->
<!--                    </label>-->
<!--                </div>-->
<!--                <div class="col-sm-2">-->
<!--                    <button class="btn btn-primary " type="button" onclick="sendSendMode()"><i class="fa fa-send-o"></i>&nbsp;发送-->
<!--                    </button>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">跑偏半径设置：</label>
                <div class="col-sm-6">
                    <input type="text" name="radius" class="form-control" oninput = "value=value.replace(/[^\d]/g,'')"
                           placeholder="请输入跑偏半径(m)">
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendRadius()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">声通信查询时间：</label>
                <div class="col-sm-6">
                    <input type="text" name="stx" class="form-control" maxlength="6"
                           placeholder="请输入查询时间xx[天]xx[时]xx[时刻],不查询请输入FF">
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendstx()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">电推工作模式：</label>
               <!-- <div class="col-sm-6">
                    <input type="text" name="rotation" class="form-control" placeholder="请输入电机转速">
                </div>-->
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="8"  name="rotation">调试
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="4"  name="rotation">3档
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="2"  name="rotation">2档
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1"  name="rotation">1档
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="0"  name="rotation" checked>关闭
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendRotation()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">驻航：</label>
                <div class="col-sm-2">
                    <input type="text" name="ZH" id="ZH" class="form-control" value="" placeholder="请输入坐标" style="width: auto;margin-bottom: 10px">
                    <button class="btn btn-primary " type="button" onclick="sendZH()"><i class="fa fa-send-o"></i>&nbsp;一键驻航
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">

               <!-- <div class="col-sm-6">
                    <input type="text" name="angle" class="form-control" placeholder="请输入舵角">
                </div>-->

                <label class="col-sm-3 control-label">舵角：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0"  name="angle" checked>正舵
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="30"  name="angle">左舵
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="130"  name="angle">右舵
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendAngle()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">艇体状态：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="unhooking" checked>艇体正常
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="unhooking">艇体脱钩
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendUnhooking()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">AIS避障功能：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="aisfun" checked>关闭
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="aisfun">开启
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendAISFun()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">安全模式：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="safemode" checked>关闭
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="safemode">开启
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendSafeMode()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">工作模式：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="wokemode" checked>正常
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="wokemode">连续无光照
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendWokeMode()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">载荷开关：</label>
                <div class="col-sm-6" th:with="type=${@dict.getType('sys_load_switch')}">
                    <ul th:each="dict , dictStat: ${type}">
                        <li>
                            <label th:text="${dict.dictValue + ' ' + dict.dictLabel}"></label>
                            <label class="radio-box">
                                <input type="radio"  value="0" th:checked="${ status != null && status.getChecked(dictStat.index,0)}" th:name="load+${dict.dictValue}">关
                            </label>
                            <label class="radio-box">
                                <input type="radio" value="1" th:checked="${status != null && status.getChecked(dictStat.index,1)}"  th:name="load+${dict.dictValue}">开
                            </label>
                        </li>
                    </ul>
<!--                    <select name="load" class="form-control m-b" th:with="type=${@dict.getType('sys_load_switch')}">-->
<!--                        <option th:each="dict : ${type}" th:text="${dict.dictValue + ' ' + dict.dictLabel}"-->
<!--                                th:value="${dict.dictValue}"></option>-->
<!--                    </select>-->
<!--                    <select name="load" class="form-control m-b" th:with="type=${@dict.getType('sys_load_switch')}">-->
<!--                        <option th:each="dict : ${type}" th:text="${dict.dictValue + ' ' + dict.dictLabel}"-->
<!--                                th:value="${dict.dictValue}"></option>-->
<!--                    </select>-->
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendLoad()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
<!--                <div class="col-sm-3">-->
<!--                    <button class="btn btn-primary" type="button" onclick="power(1)">-->
<!--                        <i class="fa fa-power-off"></i>&nbsp;开-->
<!--                    </button>-->
<!--                    <button class="btn btn-danger" type="button" onclick="power(0)">-->
<!--                        <i class="fa fa-power-off"></i>&nbsp;关-->
<!--                    </button>-->
<!--                </div>-->
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">浮块状态：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="1" name="recovery" checked>释放
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="0" name="recovery">回收
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendRecovery()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">声光报警器：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="slalarm" checked>正常
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="slalarm">报警
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendSLAlarm()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">数据存储自动销毁功能：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="destryfun" checked>关闭
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="destryfun">开启
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendDestryfun()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">数据自毁：</label>
                <div class="col-sm-6">

                </div>
                <div class="col-sm-2">
                    <button class="btn btn-danger" type="button" onclick="destroy()"><i class="fa fa-trash-o"></i>&nbsp;自毁
                    </button>
                </div>
            </div>
        </div>
    </div>

    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">平台自动注水销毁功能：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="sinkdestry" checked>关闭
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="sinkdestry">开启
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendSinkDestryfun()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">平台自沉：</label>
                <div class="col-sm-6">
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-danger" type="button" onclick="sink()"><i class="fa fa-trash-o"></i>&nbsp;自沉
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">是否加密：</label>
                <div class="col-sm-6">
                    <label class="radio-box">
                        <input type="radio" value="0" name="encrypt" checked>不加密
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" name="encrypt">加密
                    </label>
                </div>
                <div class="col-sm-2">
                    <button class="btn btn-primary " type="button" onclick="sendEncrypt()"><i class="fa fa-send-o"></i>&nbsp;发送
                    </button>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">自动下发：</label>
                <div class="col-sm-6">
                    间隔时间:<input type="text" name="periodTime" class="form-control" value="5" placeholder="请输入间隔时间/分">
                    海域情况:<select name="seaArea" class="form-control">
                    <option value="0" selected>正常</option>
                    <option value="1">异常</option>
                </select>
                    天气情况:<select name="weather"  class="form-control">
                    <option value="0" selected>良好</option>
                    <option value="1">糟糕</option>
                </select>
                    是否近场:<select name="closeArea"  class="form-control">
                    <option value="1">是</option>
                    <option value="0" selected>否</option>
                </select>
                </div>
                <div class="col-sm-3">
                    <button class="btn btn-primary" type="button" onclick="autoAction(1)">
                        <i class="fa fa-power-off"></i>&nbsp;开
                    </button>
                    <button class="btn btn-danger" type="button" onclick="autoAction(0)">
                        <i class="fa fa-power-off"></i>&nbsp;关
                    </button>
                </div>
            </div>
        </div>
</div>
<th:block th:include="include :: footer"/>

<script type="text/javascript">

    function sendEncrypt(){
        let value = $('input[name=encrypt]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择是否加密', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('encrypt', value)
        })
    }

    function sendUnhooking(){
        let value = $('input[name=unhooking]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择艇体状态', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('unhooking', value)
        })
    }

    function sendRecovery(){
        let value = $('input[name=recovery]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择回收浮块状态', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('recovery', value)
        })
    }

    function sendSLAlarm(){
        let value = $('input[name=slalarm]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择声光报警器状态', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('slalarm', value)
        })
    }

    function sendDestryfun(){
        let value = $('input[name=destryfun]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择数据存储自动销毁功能状态', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('destryfun', value)
        })
    }

    function sendSinkDestryfun(){
        let value = $('input[name=sinkdestry]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('平台自动注水销毁功能状态', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('sinkdestry', value)
        })
    }



    function sendAISFun(){
        let value = $('input[name=aisfun]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择AIS避障功能状态', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('aisfun', value)
        })
    }

    function sendSafeMode(){
        let value = $('input[name=safemode]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择安全模式状态', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('safemode', value)
        })
    }

    function sendWokeMode(){
        let value = $('input[name=wokemode]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择工作模式', modal_status.WARNING)
        $.modal.confirm('确认进行该操作?', () => {
            sendCmd('wokemode', value)
        })
    }


    function autoAction(type){
        const periodTime = $('input[name=periodTime]').val();
        const seaArea = $('select[name=seaArea]').val();
        const closeArea = $('select[name=closeArea]').val();
        const weather = $('select[name=weather]').val();

        if(type && !periodTime){
            $.modal.alert("请输入间隔时间");
            return;
        }
        let value = 0;
        if(type){
            value = periodTime * 10 + parseInt(seaArea+''+weather+''+closeArea,2);
        }
        $.modal.confirm('确认发送该信息?', () => {
            sendCmd('auto',value);
        })
    }
    function sendLoad() {
        let binaryNumber  = "";

        for(let i=0;i<7;i++) {
            let value = $('input[name=load'+i+']:checked').val();
            if($.common.isEmpty(value)){
                return $.modal.msg('请选择载荷控制', modal_status.WARNING)
            }
            binaryNumber = (value+"").concat(binaryNumber);
        }
        let val = parseInt(binaryNumber,2).toString(10)
        //console.log(val);
        $.modal.confirm('确认开关载荷?', () => {
            sendCmd('load', val)
        })
    }

    function power(type) {
        let value = $('select[name=load]').val()
        $.modal.confirm('确认开关载荷?', () => {
            sendCmd('load', type * 100 + value)
        })
    }

    // 手自动切换、北斗目标地址切换、发送模式切换、跑偏半径设置、航迹点设置、航路自动规划、数据自毁、电机转速等。 ? 舵角
    // mode address send radius point path destroy rotation angle

    function sendMode() {
        let value = $('input[name=mode]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择模式', modal_status.WARNING)
        $.modal.confirm('确认进行模式切换?', () => {
            sendCmd('mode', value)
        })
    }

    function sendAddress() {
        let value = $('input[name=address]').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请填写北斗目标地址', modal_status.WARNING)
        $.modal.confirm('确认发送北斗目标地址切换?', () => {
            sendCmd('address', value)
        })
    }

    // function sendBoatID() {
    //     let value = $('input[name=boatid]').val()
    //     if ($.common.isEmpty(value)) return $.modal.msg('请填写修改的ID号', modal_status.WARNING)
    //     $.modal.confirm('确认修改艇端ID号?', () => {
    //         sendCmd('boatid', value)
    //     })
    // }

    function sendBoatTime() {
        let value = $('input[name=boatfrequency]').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请填写修改的时间', modal_status.WARNING)
        $.modal.confirm('确认修改艇端上报时间频率?', () => {
            sendCmd('boatfrequency', value)
        })
    }

    function sendSendMode() {
        let value = $('input[name=sendMode]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择发送模式', modal_status.WARNING)
        $.modal.confirm('确认切换发送模式?', () => {
            sendCmd('send', value)
        })
    }

    function sendRadius() {
        let value = $('input[name=radius]').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请填写跑偏半径', modal_status.WARNING)
        $.modal.confirm('确认设置跑偏半径?', () => {
            sendCmd('radius', value)
        })
    }


    function sendstx() {
        let value = $('input[name=stx]').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请填写查询时间', modal_status.WARNING)
        $.modal.confirm('确认设置跑偏半径?', () => {
            sendCmd('stx', value)
        })
    }

    function sendRotation() {
        let value = $('input[name=rotation]:checked').val()
        if ($.common.isEmpty(value)) return $.modal.msg('请选择电机工作模式', modal_status.WARNING)
        $.modal.confirm('确认该电机工作模式?', () => {
            sendCmd('rotation', value)
        })
    }

    function sendAngle() {
        let value = $('input[name=angle]:checked').val();
        if ($.common.isEmpty(value)) return $.modal.msg('请选择舵令', modal_status.WARNING)
        $.modal.confirm('确认设置该舵令?', () => {
            sendCmd('angle', value)
        })
    }

    function sendZH() {
        var inputZH = document.getElementById('ZH').value;
        // 使用split方法将字符串按逗号分隔成数组

        if(inputZH==0){
            $.modal.confirm('确认进行驻航操作吗？', () => {
                sendCmd('oneclickZH', 1)
            })
        }else{
            $.modal.confirm('确认进行驻航操作吗？', () => {
                sendCmd('oneclickZH', 1,inputZH)
            })
        }

    }
    function destroy() {
        $.modal.confirm('确认进行消息自毁吗', () => {
            sendCmd('destroy', 1)
        })
    }

    function sendCmd(cmdCode, value,position) {
        $.modal.loading('发送中');
        fetch('/cmd/ctrl', {
            method: 'post',
            body: JSON.stringify({
                boatCode: $('input[name=boatCode]').val(),
                cmdCode,
                value,
                position,
            }),
            headers: {
                'Content-Type': 'application/json;charset=UTF-8',
            }
        }).then(res => res.json()) //这里必须要先转换一下
            .then(function (res) {
            $.modal.closeLoading();
            if (res.redirected) {
                if (res.url.includes('login')) {
                    alert('登录状态失效，请重新登录')
                }
                window.location.replace(res.url)
            } else if (res.code === 0) {
                $.modal.msg('发送成功', modal_status.SUCCESS)
            } else {
                $.modal.msg(res.msg, modal_status.FAIL)
            }
        }).catch((reason) => {
            $.modal.closeLoading();
            $.modal.msg('网络连接失败', modal_status.FAIL)
        })
    }

    function sink() {
        $.modal.confirm('确认进行平台自沉吗', () => {
            sendCmd('sink', 1)
        })
    }
</script>
</div>
</body>
</html>
